<?php

Yii::import('zii.widgets.CBreadcrumbs');

class LGBreadcrumbs extends CBreadcrumbs {

    public $tagName = 'div';
    public $htmlOptions = array('id' => 'breadcrumbs');
    public $encodeLabel = true;
    public $homeLink;
    public $links = array();
    public $separator = '';

    public function run() {        
        if (empty($this->links))
            return;

        echo CHtml::openTag($this->tagName, $this->htmlOptions) . "\n";
        $links = array();
        if ($this->homeLink === null)
            $links[] = '<span>' . CHtml::link(Yii::t('zii', 'Home'), Yii::app()->homeUrl) . '</span>';
        else if ($this->homeLink !== false)
            $links[] = '<span>' . $this->homeLink . '</span>';
        foreach ($this->links as $label => $url) {
            if (is_string($label) || is_array($url))
                $links[] = '<span>' . CHtml::link($this->encodeLabel ? CHtml::encode($label) : $label, $url) . '</span>';
            else
                $links[] = '<span>' . ($this->encodeLabel ? CHtml::encode($url) : $url) . '</span>';
        }
        echo implode($this->separator, $links);
        echo CHtml::closeTag($this->tagName);
    }

}
?>
